package cn.steam.foo;

import cn.steam.foo.dao.UserDao;
import cn.steam.foo.entity.User;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhang jintao on 2022/05/29
 **/
class InitUserTest extends FooApplicationTest{

    @Autowired
    UserDao userDao;

    @Test
    void init() {
        List<User> users = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            String englishName = Riven.englishName();
            int age = Riven.age();
            User user = User.builder()
                    .name(Riven.name())
                    .englishName(englishName)
                    .age(age)
                    .email(Riven.email(englishName))
                    .address(Riven.city())
                    .idCard(Riven.idCard(age))
                    .phone(Riven.telephone()).build();
            users.add(user);
        }
        userDao.saveAll(users);
    }

    @Test
    void get() {
        userDao.findAll().forEach(System.out::println);
    }
}
